package com.qf.rabbitmq.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyConfig {

    //声明队列,创建了一个名字叫rspringboot队列
    @Bean
    public Queue jiuyu(){
        return new Queue("rspringboot");
    }

    @Bean
    public Queue xindefengbao(){
        return new Queue("hjnlinonjuhbh;n");
    }

    //声明交换机
    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange("bgbbkjbk");
    }

    @Bean
    public Binding bindingQueue2Fanout(Queue xindefengbao, FanoutExchange exchange){
        return BindingBuilder.bind(xindefengbao).to(exchange);
    }

    @Bean
    public Queue queueWithDirect(){
        return new Queue("hjknkjnkj");
    }

    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("gvjvjbjkbi");
    }

    //绑定队列到交换机
    @Bean
    public Binding bindingQueue2Direct(Queue queueWithDirect, DirectExchange exchange){
        return BindingBuilder.bind(queueWithDirect).to(exchange).with("vhjbvjhv");
    }

    //多绑定几个 key
    @Bean
    public Binding bindQueue2Direct2(Queue queueWithDirect, DirectExchange exchange) {
        return BindingBuilder.bind(queueWithDirect).to(exchange).with("diergekey");
    }

    @Bean
    public Queue queueWithTopic() {

        return new Queue("bangdingtopic");
    }

    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange("suibiantopic");
    }
    //绑定队列到交换机
    @Bean
    public Binding bindQueue2Topic(Queue queueWithTopic, TopicExchange exchange) {
        return BindingBuilder.bind(queueWithTopic).to(exchange).with("*.abc");
    }
    //如果要绑定多个就多复制几个
}
